/*
 * =====================================================================================
 *
 *       Filename:  human.cpp
 *
 *    Description:  A human can eat
 *
 *        Version:  1.0
 *        Created:  07/29/09 10:30:42
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Gestrom Drawn (mn), zhcfreesea@gmail.com
 *        Company:  zhc
 *
 * =====================================================================================
 */

#include"tuple.h"
#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{
    Tuple *tuple = new Tuple;
    static Time life_limit = 40;
    while(tuple->get_time() < life_limit){
        tuple->show_tuple();
        Tuple tmp_tuple = Tuple(*tuple);

        /*modify action excitation state by the last tuple one by one, then add time*/
        try{
            //for next time of action
            if(tmp_tuple.get_excitation() == HUNGER){
                tuple->set_action(EAT);
            }else if(tmp_tuple.get_excitation() == NONE){
                tuple->set_action(SLEEP);
            }else{
                throw tuple->get_action();
            }
            //for next time of excitation
            if(tmp_tuple.get_state() == FULL){
                tuple->set_excitation(NONE);
            }else if(tmp_tuple.get_state() == HUNGRY){
                tuple->set_excitation(HUNGER);
            }else{
                throw tuple->get_state();
            }
            //for next time of state
            if(tmp_tuple.get_time() % 9 == 1){
                tuple->set_state(HUNGRY);
            }else if(tmp_tuple.get_action() == EAT){
                tuple->set_state(FULL);
            }else{
                ;//keep state still
            }
            //for next time of time
            tuple->time_add();
        }
        catch (Action a){
            cout << "action is " << a << endl;
        }
        catch (Excitation e){
            cout << "excitation is " << e << endl;
        }
    }
}

//void action_eat(Tuple *tuple)
//{
//    tuple->set_action(EAT);
//}
//void action_
